#include <iostream>
#include <stack>
using namespace std;
int main(){
    int m,n,k;

    cin>>m>>n>>k;
    while(k--){
        int j=0;
        int flag =1;
        stack<int> c;
        int arr[1001];
        for(int i=0;i<n;i++){
            cin>>arr[i];
        }
        for(int i=1;i<=n;i++){
            c.push(i);
            if(c.size() > m){flag =0;break;}
            while(!c.empty()&&arr[j]==c.top()){
                c.pop();
                j=j+1;
            }
        }
        if(flag&&j==n){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
    }
    return 0;
}